package com.letoken.platform.admin.controller;

import com.letoken.platform.admin.service.AdminConfigService;
import com.letoken.platform.pub.annotation.auth.Permission;
import com.letoken.platform.pub.annotation.pub.Trim;
import com.letoken.platform.pub.constant.RedisKeyConstant;
import com.letoken.platform.pub.enums.TokenApprovedStateEnum;
import com.letoken.platform.pub.enums.TokenTransactionStatusEnum;
import com.letoken.platform.pub.req.PageData;
import com.letoken.platform.pub.res.ApiResponse;
import com.letoken.platform.repo.admin.req.config.*;
import com.letoken.platform.repo.admin.res.config.*;
import com.letoken.platform.repo.admin.res.user.QueryRoleTypeRes;
import com.letoken.platform.repo.common.CommDropDownRes;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @author letokenlabs
 * @date 2022/11/24$
 */
@RestController
@RequestMapping("/config")
@Api(tags = "admin系统相关配置")
public class AdminConfigController {


    @Autowired
    private AdminConfigService adminConfigService;


    @PostMapping("/query/token/list")
    @ApiOperation(value = "下拉框-资产币种", notes = "下拉框-资产币种")
    public ApiResponse<List<QueryTokenListRes>> queryRechargeTokenList() {
        return ApiResponse.create(adminConfigService.queryReTokenList());
    }


    @Permission(uri = "/config/recharge/add",qx = "/config/recharge/add")
    @Trim
    @PostMapping("/recharge/add")
    @ApiOperation(value = "添加admin充值配置", notes = "添加admin充值配置")
    public ApiResponse addRechargeConfig(@RequestBody @Validated AddRechargeConfigReq req) {
        adminConfigService.addRechargeConfig(req);


        return ApiResponse.create();
    }

    @Permission(uri = "/config/recharge/query",qx = "/configuration/recharge")
    @PostMapping("/recharge/query")
    @ApiOperation(value = "查询admin充值配置", notes = "查询admin充值配置")
    public ApiResponse<PageData<QueryRechargeConfigRes>> queryRechargeConfigList(@RequestBody @Validated QueryRechargeConfigReq req) {
        return ApiResponse.create(adminConfigService.queryRechargeConfigList(req));
    }

    @Permission(uri = "/config/recharge/update",qx = "/config/recharge/update")
    @Trim
    @PostMapping("/recharge/update")
    @ApiOperation(value = "修改admin充值配置", notes = "修改admin充值配置")
    public ApiResponse updateRechargeConfig(@RequestBody @Validated UpdateRechargeConfigReq req) {
        adminConfigService.updateRechargeConfig(req);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/recharge/locked",qx = "/config/recharge/locked")
    @PostMapping("/recharge/locked")
    @ApiOperation(value = "是否禁用充值配置", notes = "是否禁用充值配置")
    public ApiResponse isLockedRechargeConfig(@RequestBody @Validated IsLockedRechargeReq req) {
        adminConfigService.isLockedRechargeConfig(req.getId(), req.getFlag());
        return ApiResponse.create();
    }


    @Permission(uri = "/config/withdraw/add",qx = "/config/withdraw/add")
    @Trim
    @PostMapping("/withdraw/add")
    @ApiOperation(value = "新增钱包提现配置", notes = "新增钱包提现配置")
    public ApiResponse addExtractConfig(@RequestBody @Validated AddExtractConfigReq req) {
        adminConfigService.addExtractConfig(req);
        return ApiResponse.create();
    }


    @Permission(uri = "/config/withdraw/update",qx ="/config/withdraw/update")
    @Trim
    @PostMapping("/withdraw/update")
    @ApiOperation(value = "修改钱包提现配置", notes = "修改钱包提现配置")
    public ApiResponse updateExtractConfig(@RequestBody @Validated UpdateExtractConfigReq req) {
        adminConfigService.updateExtractConfig(req);

        return ApiResponse.create();
    }

    @Permission(uri = "/config/withdraw/delete",qx = "/config/withdraw/delete")
    @Trim
    @PostMapping("/withdraw/delete")
    @ApiOperation(value = "删除钱包提现配置", notes = "删除钱包提现配置")
    public ApiResponse deleteExtractConfig(@RequestBody @Validated DeleteExtractConfigReq req) {
        adminConfigService.deleteExtractConfig(req);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/withdraw/query",qx = "/configuration/withdraw")
    @Trim
    @PostMapping("/withdraw/query")
    @ApiOperation(value = "查询钱包提现配置", notes = "查询钱包提现配置")
    public ApiResponse<PageData<QueryExtractConfigRes>> queryExtractConfig(@RequestBody @Validated QueryExtractConfigReq req) {
        return ApiResponse.create(adminConfigService.queryExtractConfigList(req));
    }


    @PostMapping("/query/level/list")
    @ApiOperation(value = "下拉框-生态等级", notes = "下拉框-生态等级")
    public ApiResponse<PageData<QueryLevelConfigRes>> queryLevelList() {
        return ApiResponse.create(adminConfigService.queryLevelList());
    }

    @PostMapping("/query/circulationtype")
    @ApiOperation(value = "下拉框-流通类型", notes = "下拉框-流通类型")
    public ApiResponse<List<CommDropDownRes>> queryCirculationtypeList() {
        List<CommDropDownRes> res = new ArrayList<>(2);
        CommDropDownRes dropDown = new CommDropDownRes();
        dropDown.setId(1);
        dropDown.setName("周期流通");
        res.add(dropDown);
        dropDown = new CommDropDownRes();
        dropDown.setId(2);
        dropDown.setName("分享流通");
        res.add(dropDown);
        return ApiResponse.create(res);
    }

    @PostMapping("/query/deposittype")
    @ApiOperation(value = "下拉框-充值类型", notes = "下拉框-充值类型")
    public ApiResponse<List<CommDropDownRes>> queryDepositTypeList() {
        //充值类型(0系统 1链上)
        List<CommDropDownRes> res = new ArrayList<>(2);
        CommDropDownRes dropDown = new CommDropDownRes();
        dropDown.setId(0);
        dropDown.setName("系统");
        res.add(dropDown);
        dropDown = new CommDropDownRes();
        dropDown.setId(1);
        dropDown.setName("链上");
        res.add(dropDown);
        return ApiResponse.create(res);
    }

    @PostMapping("/query/withdrawtype")
    @ApiOperation(value = "下拉框-提现类型", notes = "下拉框-提现类型")
    public ApiResponse<List<CommDropDownRes>> queryWithdrawTypeList() {
        // 提现类型 0平台互转 1链上提现
        List<CommDropDownRes> res = new ArrayList<>(2);
        CommDropDownRes dropDown = new CommDropDownRes();
        dropDown.setId(0);
        dropDown.setName("平台互转");
        res.add(dropDown);
        dropDown = new CommDropDownRes();
        dropDown.setId(1);
        dropDown.setName("链上提现");
        res.add(dropDown);
        return ApiResponse.create(res);
    }

    @PostMapping("/query/auditstatus")
    @ApiOperation(value = "下拉框-审核状态", notes = "下拉框-审核状态")
    public ApiResponse<List<CommDropDownRes>> queryAuditStatusList() {
        TokenApprovedStateEnum[] StateEnums = TokenApprovedStateEnum.values();
        List<CommDropDownRes> res = new ArrayList<>();
        for (TokenApprovedStateEnum state : StateEnums) {
            CommDropDownRes dropDown = new CommDropDownRes();
            dropDown.setId(state.getValue());
            dropDown.setName(state.getText());
            res.add(dropDown);
        }
        return ApiResponse.create(res);
    }

    @PostMapping("/query/withdrawstatus")
    @ApiOperation(value = "下拉框-提现状态", notes = "下拉框-提现状态")
    public ApiResponse<List<CommDropDownRes>> queryWithdrawStatus() {
        // 提现类型 0平台互转 1链上提现
        List<CommDropDownRes> res = new ArrayList<>();
        for (TokenTransactionStatusEnum statusEnum : TokenTransactionStatusEnum.values()) {
            CommDropDownRes dropDown = new CommDropDownRes();
            dropDown.setId(statusEnum.getValue());
            dropDown.setName(statusEnum.getText());
            res.add(dropDown);
        }
        return ApiResponse.create(res);
    }

    @Permission(uri = "/config/quickswap/query",qx = "/configuration/flash")
    @Trim
    @PostMapping("/quickswap/query")
    @ApiOperation(value = "查询闪兑配置", notes = "查询闪兑配置")
    public ApiResponse<PageData<QueryQuickswapConfigRes>> queryQuickswapList(@RequestBody @Validated QueryQuickswapConfigReq req) {
        return ApiResponse.create(adminConfigService.queryQuickswapList(req));
    }

    @Permission(uri = "/config/quickswap/add",qx = "/config/quickswap/add")
    @Trim
    @PostMapping("/quickswap/add")
    @ApiOperation(value = "新增闪兑配置", notes = "新增闪兑配置")
    public ApiResponse addQuickswapConfig(@RequestBody @Validated AddQuickswapConfigReq req) {
        adminConfigService.addQuickswapConfig(req);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/quickswap/update",qx = "/config/quickswap/update")
    @Trim
    @PostMapping("/quickswap/update")
    @ApiOperation(value = "修改闪兑配置", notes = "修改闪兑配置")
    public ApiResponse updateQuickswapConfig(@RequestBody @Validated UpdateQuickswapConfigReq req) {
        adminConfigService.updateQuickswapConfig(req);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/quickswap/delete",qx="/config/quickswap/delete")
    @Trim
    @PostMapping("/quickswap/delete")
    @ApiOperation(value = "删除闪兑配置", notes = "删除闪兑配置")
    public ApiResponse deleteQuickswapConfig(@RequestBody @Validated DeleteQuickswapConfigReq req) {
        adminConfigService.deleteQuickswapConfig(req);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/letoken/issue/query",qx = "/configuration/coin")
    @Trim
    @PostMapping("/letoken/issue/query")
    @ApiOperation(value = "查询铸币配置", notes = "查询铸币配置")
    public ApiResponse<QueryIssueConfigRes> queryIssueList(@RequestBody @Validated QueryIssueConfigReq req) {
        return ApiResponse.create(adminConfigService.queryIssueList(req));
    }

    @Permission(uri = "/config/letoken/issue/update",qx = "/config/letoken/issue/update")
    @Trim
    @PostMapping("/letoken/issue/update")
    @ApiOperation(value = "修改铸币配置", notes = "修改铸币配置")
    public ApiResponse updateIssueConfig(@RequestBody @Validated UpdateIssueConfigReq req) {
        adminConfigService.updateIssueConfig(req);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/letoken/circulation/query",qx = "/configuration/coin")
    @Trim
    @PostMapping("/letoken/circulation/query")
    @ApiOperation(value = "查询流通配置", notes = "查询流通配置")
    public ApiResponse<QueryCirculationConfigRes> queryCirculationList(@RequestBody @Validated QueryCirculationConfigReq req) {
        return ApiResponse.create(adminConfigService.queryCirculationList(req));
    }

    @Permission(uri = "/config/letoken/circulation/update",qx = "/config/letoken/circulation/update")
    @Trim
    @PostMapping("/letoken/circulation/update")
    @ApiOperation(value = "修改流通配置", notes = "修改流通配置")
    public ApiResponse updateCirculationConfig(@RequestBody @Validated UpdateCirculationConfigReq req) {
        adminConfigService.updateCirculationConfig(req);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/letoken/reward/query",qx = "/configuration/award")
    @Trim
    @PostMapping("/letoken/reward/query")
    @ApiOperation(value = "查询奖励配置", notes = "查询奖励配置")
    public ApiResponse<QueryRewardConfigRes> queryReward() {
        return ApiResponse.create(adminConfigService.queryReward());
    }

    @Permission(uri = "/config/letoken/reward/update",qx = "/config/letoken/reward/update")
    @Trim
    @PostMapping("/letoken/reward/update")
    @ApiOperation(value = "修改奖励配置", notes = "修改奖励配置")
    public ApiResponse updateRewardConfig(@RequestBody @Validated UpdateRewardConfigReq req) {
        adminConfigService.updateRewardConfig(req);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/version/query",qx = "/configuration/version")
    @Trim
    @PostMapping("/version/query")
    @ApiOperation(value = "查询版本更新", notes = "查询版本更新")
    public ApiResponse<PageData<QueryVersionRes>> queryVersionList(@RequestBody @Validated QueryVersionReq req) {
        return ApiResponse.create(adminConfigService.queryVersionList(req));
    }

    @Permission(uri = "/config/version/query",qx = "/configuration/version")
    @Trim
    @PostMapping("/version/query/{id}")
    @ApiOperation(value = "根据id查询版本更新", notes = "根据id查询版本更新")
    public ApiResponse<QueryVersionByIdRes> queryVersionById(@PathVariable("id") Integer id) {
        return ApiResponse.create(adminConfigService.queryVersionById(id));
    }

    @Permission(uri = "/config/version/add",qx = "/config/version/add")
    @Trim
    @PostMapping("/version/add")
    @ApiOperation(value = "新增版本更新", notes = "新增版本更新")
    public ApiResponse addVersionConfig(@RequestBody @Validated AddVersionReq req) {
        adminConfigService.addVersionConfig(req);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/version/update",qx = "/config/version/update")
    @Trim
    @PostMapping("/version/update")
    @ApiOperation(value = "修改版本更新", notes = "修改版本更新")
    public ApiResponse updateVersionConfig(@RequestBody @Validated UpdateVersionReq req) {
        adminConfigService.updateVersionConfig(req);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/version/delete",qx = "/config/version/delete")
    @Trim
    @PostMapping("/version/delete")
    @ApiOperation(value = "删除版本更新", notes = "删除版本更新")
    public ApiResponse deleteVersionConfig(@RequestBody @Validated DeleteVersionReq req) {
        adminConfigService.deleteVersionConfig(req);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/version/notForceUpdate",qx = "/config/version/forceUpdate")
    @Trim
    @PostMapping("/version/notForceUpdate/{id}")
    @ApiOperation(value = "不强制版本更新", notes = "不强制版本更新")
    public ApiResponse<QueryVersionByIdRes> notForceUpdateVersionById(@PathVariable("id") Integer id) {
        adminConfigService.notForceUpdateVersionById(id);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/version/forceUpdate",qx = "/config/version/forceUpdate")
    @Trim
    @PostMapping("/version/forceUpdate/{id}")
    @ApiOperation(value = "强制版本更新", notes = "强制版本更新")
    public ApiResponse<QueryVersionByIdRes> forceUpdateVersionById(@PathVariable("id") Integer id) {
        adminConfigService.forceUpdateVersionById(id);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/announcement/query",qx = "/configuration/announcement")
    @Trim
    @PostMapping("/announcement/query")
    @ApiOperation(value = "查询公告配置列表", notes = "查询公告配置列表")
    public ApiResponse<PageData<QueryAnnouncementRes>> queryAnnouncementList(@RequestBody @Validated QueryAnnouncementReq req) {
        return ApiResponse.create(adminConfigService.queryAnnouncementList(req));
    }

    @Permission(uri = "/config/announcement/query/one",qx = "/configuration/announcement")
    @Trim
    @PostMapping("/announcement/query/one")
    @ApiOperation(value = "查询一级公告配置列表", notes = "查询一级公告配置列表")
    public ApiResponse<PageData<QueryAnnouncementRes>> queryOneLevelAnnouncementList(@RequestBody @Validated QueryAnnouncementReq req) {
        return ApiResponse.create(adminConfigService.queryOneLevelAnnouncementList(req));
    }

    @Permission(uri = "/config/announcement/query/two",qx = "/configuration/announcement")
    @Trim
    @PostMapping("/announcement/query/two/{pid}")
    @ApiOperation(value = "查询二级公告配置列表", notes = "查询二级公告配置列表")
    public ApiResponse<List<QueryAnnouncementRes>> queryTwoLevelAnnouncementList(@PathVariable("pid") Long pid) {
        return ApiResponse.create(adminConfigService.queryTwoLevelAnnouncementList(pid));
    }

    @Permission(uri = "/config/announcement/query",qx = "/configuration/announcement")
    @Trim
    @PostMapping("/announcement/query/{id}")
    @ApiOperation(value = "根据id查询公告配置", notes = "根据id查询公告配置")
    public ApiResponse<QueryAnnouncementByIdRes> queryAnnouncementById(@PathVariable("id") Long id) {
        return ApiResponse.create(adminConfigService.queryAnnouncementById(id));
    }

    @Trim
    @PostMapping("/announcement/query/pidAndLang")
    @Permission(uri = "/config/announcement/query/pidAndLang",qx = "/configuration/announcement")
    @ApiOperation(value = "根据父id和语言查询公告配置", notes = "根据父id和语言查询公告配置")
    public ApiResponse<QueryAnnouncementByIdRes> queryByPidAndLang(@RequestBody @Validated QueryPidAndLangReq req) {
        return ApiResponse.create(adminConfigService.queryByPidAndLang(req));
    }

    @Permission(uri = "/config/announcement/add",qx = "/configuration/announcement/add")
    @Trim
    @PostMapping("/announcement/add")
    @ApiOperation(value = "新增公告配置", notes = "新增公告配置")
    public ApiResponse addAnnouncementConfig(@RequestBody @Validated AddAnnouncementReq req) {
        adminConfigService.addAnnouncementConfig(req);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/announcement/update",qx = "/config/announcement/update")
    @Trim
    @PostMapping("/announcement/update")
    @ApiOperation(value = "修改公告配置", notes = "修改公告配置")
    public ApiResponse updateAnnouncementConfig(@RequestBody @Validated UpdateAnnouncementReq req) {
        adminConfigService.updateAnnouncementConfig(req);
        return ApiResponse.create("修改公告配置成功！");
    }

    @Permission(uri = "/config/announcement/delete",qx ="/config/announcement/delete")
    @Trim
    @PostMapping("/announcement/delete")
    @ApiOperation(value = "删除公告配置", notes = "删除公告配置")
    public ApiResponse deleteAnnouncementConfig(@RequestBody @Validated DeleteAnnouncementReq req) {
        adminConfigService.deleteAnnouncementConfig(req);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/announcement/show",qx = "/config/announcement/hide")
    @Trim
    @PostMapping("/announcement/show/{id}")
    @ApiOperation(value = "展示公告配置", notes = "展示隐藏公告配置")
    public ApiResponse ShowAnnouncementConfig(@PathVariable("id") Long id) {
        adminConfigService.ShowAnnouncementConfig(id);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/announcement/hide",qx = "/config/announcement/hide")
    @Trim
    @PostMapping("/announcement/hide/{id}")
    @ApiOperation(value = "隐藏公告配置", notes = "隐藏公告配置")
    public ApiResponse hideAnnouncementConfig(@PathVariable("id") Long id) {
        adminConfigService.hideAnnouncementConfig(id);
        return ApiResponse.create();
    }

    @Permission(uri = "/config/useragreement/show",qx = "/configuration/protocol")
    @PostMapping("/useragreement/show")
    @ApiOperation(value = "查询用户协议", notes = "查询用户协议")
    public ApiResponse<String> queryUserAgreementList() {
        return ApiResponse.create(adminConfigService.queryUserAgreementList());
    }

    @Permission(uri = "/config/useragreement/update",qx = "/config/useragreement/update")
    @Trim
    @PostMapping("/useragreement/update")
    @ApiOperation(value = "修改用户协议", notes = "修改用户协议")
    public ApiResponse updateUserAgreementConfig(@RequestBody @Validated UpdateUserAgreementReq req) {
        adminConfigService.updateUserAgreementConfig(req);
        return ApiResponse.create("修改成功");
    }

    @PostMapping("/aboutus/show")
    @ApiOperation(value = "查询关于我们", notes = "查询关于我们")
    public ApiResponse<String> queryAboutUsList() {
        return ApiResponse.create(adminConfigService.queryAboutUsList());
    }

    @Trim
    @PostMapping("/aboutus/update")
    @ApiOperation(value = "修改关于我们", notes = "修改关于我们")
    public ApiResponse updateAboutUs(@RequestBody @Validated UupdateAboutUsReq req) {
        adminConfigService.updateAboutUs(req);
        return ApiResponse.create("修改成功");
    }

    @PostMapping("/query/roletype")
    @ApiOperation(value = "角色类型下拉框", notes = "角色类型下拉框")
    public ApiResponse<List<QueryRoleTypeRes>> queryRoleType() {
        return ApiResponse.create(adminConfigService.queryRoleType());
    }

    @PostMapping("/guide/query")
    @ApiOperation(value = "查询用户指南", notes = "查询用户指南")
    public ApiResponse queryGuideList(@RequestBody @Validated QueryGuideReq req) {
        return ApiResponse.create(adminConfigService.queryGuideList(req));
    }


    @PostMapping("/guide/add")
    @ApiOperation(value = "新增用户指南", notes = "新增用户指南")
    public ApiResponse addGuideList(@RequestBody @Validated AddGuideReq req) {
        adminConfigService.addGuideList(req);
        return ApiResponse.create("新增用户指南成功！");
    }


    @PostMapping("/guide/update")
    @ApiOperation(value = "修改用户指南", notes = "修改用户指南")
    public ApiResponse updateGuideList(@RequestBody @Validated UpdateGuideReq req) {
        adminConfigService.updateGuideList(req);
        return ApiResponse.create("修改用户指南成功！");
    }

    @PostMapping("/guide/delete")
    @ApiOperation(value = "删除用户指南", notes = "删除用户指南")
    public ApiResponse deleteGuideList(@PathVariable("id") Long id) {
        adminConfigService.deleteGuideList(id);
        return ApiResponse.create("删除用户指南成功！");
    }

    @PostMapping("/netType/query")
    @ApiOperation(value = "查询网络类型下拉框", notes = "查询网络类型下拉框")
    public ApiResponse queryNetTypeList() {
        return ApiResponse.create(adminConfigService.queryNetTypeList());
    }



    @Trim
    @PostMapping("/chainNode/add")
    @Permission(uri = "/config/chainNode/add",qx = "/config/chainNode/add")
    @ApiOperation(value = "新增网络节点配置", notes = "新增网络节点配置")
    public ApiResponse addChainNode(@RequestBody @Validated AddChainNodeReq req) {
        adminConfigService.addChainNode(req);
        return ApiResponse.create("新增网络节点成功！");
    }

//    @Trim
//    @PostMapping("/chainNode/delete")
//    @ApiOperation(value = "删除网络节点配置", notes = "删除网络节点配置")
//    public ApiResponse addChainNode(@RequestBody @Validated AddChainNodeReq req) {
//        adminConfigService.addChainNode(req);
//        return ApiResponse.create("新增网络节点成功！");
//    }

    @Permission(uri = "/config/chainNode/update",qx = "/config/chainNode/update")
    @Trim
    @PostMapping("/chainNode/update")
    @ApiOperation(value = "修改网络节点配置", notes = "修改网络节点配置")
    public ApiResponse updateChainNode(@RequestBody @Validated UpdateChainNodeReq req) {
        adminConfigService.updateChainNode(req);
        return ApiResponse.create("修改网络节点成功！");
    }


    @Permission(uri = "/config/chainNode/query",qx = "/configuration/chainNode/query")
    @Trim
    @PostMapping("/chainNode/query")
    @ApiOperation(value = "查询网络节点配置列表", notes = "查询网络节点配置列表")
    public ApiResponse<PageData<QueryChainNodeListRes>> queryChainNodeList(@RequestBody @Validated QueryChainNodeReq req) {
        return ApiResponse.create(adminConfigService.queryChainNodeList(req));
    }

    @Permission(uri = "/config/chainNode/query",qx = "/configuration/chainNode/query")
    @GetMapping("/chainNode/query/{id}")
    @ApiOperation(value = "根据id查询网络节点配置", notes = "根据id查询网络节点配置")
    public ApiResponse<QueryChainNodeListRes> queryChainNodeById(@ApiParam(example = "18") @PathVariable("id") Integer id) {
        return ApiResponse.create(adminConfigService.queryChainNodeById(id));
    }

    @Permission(uri = "/config/chainNode/isShow",qx = "/config/chainNode/isShow")
    @PostMapping("/chainNode/isShow")
    @ApiOperation(value = "启用或禁用网络节点配置", notes = "启用或禁用网络节点配置")
    public ApiResponse<?> chainNodeIsShow(@ApiParam(example = "18") @RequestParam Integer id, @ApiParam(example = "true启用/false禁用") @RequestParam Boolean flag) {
        return ApiResponse.create(adminConfigService.chainNodeIsShow(id, flag));
    }

    @Permission(uri = "/config/chainNode/address/add",qx = "/config/chainNode/address/add")
    @Trim
    @PostMapping("/chainNode/address/add")
    @ApiOperation(value = "新增网络节点地址配置", notes = "新增网络节点地址配置")
    public ApiResponse addNodeAddressNode(@RequestBody @Validated AddChainNodeAddressReq req) {
        adminConfigService.addNodeAddressNode(req);
        return ApiResponse.create("新增网络节点地址成功！");
    }

    @Permission(uri = "/config/chainNode/address/update",qx = "/config/chainNode/address/update")
    @Trim
    @PostMapping("/chainNode/address/update")
    @ApiOperation(value = "修改网络节点地址配置", notes = "修改网络节点地址配置")
    public ApiResponse updateChainNodeAddress(@RequestBody @Validated UpdateNodeAddressReq req) {
        adminConfigService.updateChainNodeAddress(req);
        return ApiResponse.create("修改网络节点成功！");
    }


    @Permission(uri = "/config/chainNode/address/query",qx = "/configuration/chainNode/query")
    @Trim
    @PostMapping("/chainNode/address/query")
    @ApiOperation(value = "查询网络节点地址配置列表", notes = "查询网络节点地址配置列表")
    public ApiResponse<PageData<QueryNodeAddressListRes>> queryNodeAddressList(@RequestBody @Validated QueryAddressNodeReq req) {
        return ApiResponse.create(adminConfigService.queryNodeAddressList(req));
    }

    @Permission(uri = "/config/chainNode/address/query",qx = "/configuration/chainNode/query")
    @GetMapping("/chainNode/address/query/{id}")
    @ApiOperation(value = "根据id查询网络节点地址配置", notes = "根据id查询网络节点地址配置")
    public ApiResponse<QueryNodeAddressRes> queryNodeAddressById(@PathVariable("id") Integer id) {
        return ApiResponse.create(adminConfigService.queryNodeAddressById(id));
    }

    @Permission(uri = "/config/chainNode/address/isShow",qx = "/config/chainNode/address/isShow")
    @PostMapping("/chainNode/address/isShow")
    @ApiOperation(value = "启用或禁用网络节点地址配置", notes = "启用或禁用网络节点地址配置")
    public ApiResponse<?> nodeAddressIsShow(@ApiParam(example = "18") @RequestParam Integer id, @ApiParam(example = "true启用/false禁用") @RequestParam Boolean flag) {
        return ApiResponse.create(adminConfigService.nodeAddressIsShow(id, flag));
    }

}
